function imageUploaderWrapper(param){
	
	var $button = param.launch_button;
    var $images = param.image_container;
	var $images_id = $images.attr('id');
	var $input = param.url_input;
	var $urls = param.init_url?param.init_url.split(','):($input.val().length?$input.val().split(','):[]);
	var $prefix = param.prefix;
	var displayOverlay = function(url) {
		$("body", window.parent.document).append($("<table id='image-uploader-overlay'><tbody><tr><td>" + '<img src="'+url+'"/>' + "</td></tr></tbody></table>").css({
			"position": "fixed",
			"top": "0px",
			"left": "0px",
			"width": "80%",
			"height": "80%",
			"background-color": "rgba(0,0,0,.5)",
			"z-index": "10000",
			"vertical-align": "middle",
			"text-align": "center",
		}));
 
		if ($("#image-uploader-overlay", window.parent.document).length > 0) {
            $("#image-uploader-overlay", window.parent.document).on('click',function(){
				$("#image-uploader-overlay", window.parent.document).remove();
			});
        } 
	}

    var uploader = new qq.FineUploaderBasic({
      button: $button[0],
      request: {
        endpoint: '/boneDatabase/images/endpoint.php'
      },
      validation: {
        allowedExtensions: ['jpeg', 'jpg', 'gif', 'png'],
        sizeLimit: 2048000 // 200 kB = 200 * 1024 bytes
      },
	  messages:{
		  typeError:"建议图片格式 {extensions}",
		  sizeError:"建议图片尺寸小于 {sizeLimit}"
	  },
      callbacks: {
		onError: function(id, name, errorReason, xhrOrXdr) {
            alert("上传无效，原因:"+errorReason);
        },
        onSubmit: function(id, fileName) {
			if($images.find('img').length > 0){
				//alert('先删除再上传');
				//return false;
				$images.empty();
			}
          $images.append('<div id="'+$images_id+'-' + id + '" class="alert"></div>');
        },
        onUpload: function(id, fileName) {
          $('#'+$images_id+'-' + id).addClass('alert-info')
                          .html('<img src="'+$prefix+'/loading.gif" alt="Initializing. Please hold."> ' +
                                '开始上传' + fileName);
        },
        onProgress: function(id, fileName, loaded, total) {
          if (loaded < total) {
            progress = Math.round(loaded / total * 100) + '% of ' + Math.round(total / 1024) + ' kB';
            $('#'+$images_id+'-' + id).removeClass('alert-info')
                            .html('<img src="'+$prefix+'/loading.gif" alt=""> ' +
                                  '上传中' + fileName + ': ' + progress);
          } else {
            $('#'+$images_id+'-' + id).addClass('alert-info')
                            .html('<img src="'+$prefix+'/loading.gif" alt=""> ' +
                                  '上传中' + fileName);
          }
        },
        onComplete: function(id, fileName, responseJSON) {
          if (responseJSON.success) {
          	alert('上传成功');
            $('#'+$images_id+'-' + id).removeClass('alert-info')
                            .addClass('alert-success')
                            .html( ''
                            	+
                            	//'<a  target="_blank" href="'+$prefix + '/' + responseJSON.uuid+'/'+fileName+'" >点击预览图片</a>');
                                  '<img src="'+$prefix + '/' + responseJSON.uuid+'/'+fileName+'" alt="' + fileName + '">');
								  
			$('#'+$images_id+'-' + id).on('click',function(){
				if($(this).find('img').length > 0){

					displayOverlay($(this).find('img').attr('src'));
				}
			});
			$input.val($prefix+ '/' + responseJSON.uuid+'/'+fileName);
          } else {
            $('#'+$images_id+'-' + id).removeClass('alert-info')
                            .addClass('alert-error')
                            .html('<i class="icon-exclamation-sign"></i> ' +
                                  '失败' + fileName + ': ' +
                                  responseJSON.error);
          }
        }
      },
      debug: true
    });
	
	var files = [];
	for(var id=0;id<$urls.length;id++){
		var parts = $urls[id].split('/');
		var file = {};
		file["name"] = parts[parts.length - 1];
		file["uuid"] = parts[parts.length - 2];
		files.push(file);
		$images.append('<div id="'+$images_id+'-' + id + '" class="alert alert-success">'
                                   +
                                  '<img src="'+$urls[id]+'" alt="' + file["name"] + '">'+
		'</div>');
		$('#'+$images_id+'-' + id).on('click',function(){
				if($(this).find('img').length > 0){
					displayOverlay($(this).find('img').attr('src'));
				}
		});
	}
	uploader.addInitialFiles(files);
}